<!DOCTYPE html>
<html>
<head>
    <title>登录</title>
{{template "admin/html-head.html"}}
</head>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <a href="../../static/index2.html"><b>Admin</b>LTE</a>
    </div>
    <!-- /.login-logo -->
    <div class="login-box-body">
        <p class="login-box-msg">Sign in to start your session</p>

        <form action="" method="post" onsubmit="return false">
            <div class="form-group has-feedback">
                <input type="text" class="form-control" name="mobile" value="18701897513" placeholder="Mobile">
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" class="form-control" name="password" value="hello7513" placeholder="Password">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="row">
                <div class="col-xs-8">
                    <div class="checkbox icheck">
                        <label>
                            <input type="checkbox"> Remember Me
                        </label>
                    </div>
                </div>
                <!-- /.col -->
                <div class="col-xs-4">
                    <button type="submit" class="btn btn-primary btn-block btn-flat">Sign In</button>
                </div>
                <!-- /.col -->
            </div>
        </form>
        <a href="#" id="forget-password">忘记密码</a><br>
        <a href="/admin/to-register" class="text-center">注册</a>
    </div>
    <!-- /.login-box-body -->
</div>
<!-- /.login-box -->

<!-- jQuery 3 -->
<script src="../../static/bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="../../static/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="../../static/plugins/iCheck/icheck.min.js"></script>
<script>
    $(function () {
        $('input').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '20%' /* optional */
        });
        $("form").on("submit", function () {
            $.ajax({
                url: '/admin/to-login',
                type: 'post', //GET
                async: true,    //或false,是否异步
                data: {
                    mobile: $("input[name=mobile]").val(),
                    password: $("input[name=password]").val()
                },
                timeout: 5000,    //超时时间
                dataType: 'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                beforeSend: function (xhr) {
                    console.log('发送前')
                },
                success: function (data, textStatus, jqXHR) {
                    if (data.code == 0){
                        location.href="/admin/welcome"
                    } else {
                        alert(data.msg)
                    }
                },
                error: function (xhr, textStatus) {
                    console.log('错误')
                },
                complete: function () {
                    console.log('结束')
                }
            })
        });

        $("#forget-password").click(function(){
            alert("默认密码：hello+手机后4位");
        })
    });
</script>
</body>
</html>
